﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="login.aspx.cs" Inherits="OnLineExam.Web.login" %>

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
	<title>在线考试系统</title> 
	<link href="assets/layui/2.2.5/css/layui.css" rel="stylesheet" />
</head>
<body><div class="layui-main">
	<form class="layui-form" id="loginForm">
		<div class="layui-form-item">
			<label class="layui-form-label">用户名</label>
			<div class="layui-input-block">
				<input type="text" name="txtUserName"   lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">密码</label>
			<div class="layui-input-block">
				<input type="password" name="txtUserPass"   lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
			</div>

		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button id="btn" type="button" class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
			</div>
		</div>
	</form></div>
	<script src="assets/layui/2.2.5/layui.js"></script>
	<script>
		//Demo
		layui.use(['form', 'jquery'], function () {
			var $ = layui.$ //重点处
            var form = layui.form;

            $(document).on('keydown', function(e){  //document为当前元素，限制范围，如果不限制的话会一直有事件
                if(e.keyCode == 13){
                    document.getElementById("btn").click();
                }
            })



			//监听提交
			form.on('submit(formDemo)', function (data) {

				$.post('LoginAjax.aspx', data.field, function (rsp) {

					if (rsp == '管理员' || rsp == '教师') {
						location.href = 'mag/main.aspx';
						return false;
					}
					else if (rsp == '学生') {
						location.href = 'StudentIndex.aspx';
						return false;
					}
					layer.msg('登录失败,请重试.');
					return false;
				});

				
				
			});
		});
	</script>
</body>
</html>
